﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Microsoft.Maps.MapControl;
using SMIL.Client.Print;

namespace SMIL_WebPart
{
    public partial class MainPage : UserControl
    {
        const string _SPSITEURL = "SPWEB";
        const string _APPKEY = "SMIL.BingMap.CredentialsKey";
        const string _HOST = "HOST";

        public MainPage()
        {
            InitializeComponent();
            Loaded += MainPage_Loaded;
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            map.CredentialsProvider = new ApplicationIdCredentialsProvider((App.Current.Resources.Contains(_APPKEY)) ? App.Current.Resources[_APPKEY] as string : "");
            SMIL.SPCommunication.Proxy.ServiceAddress = App.Current.Resources[_HOST] as string;
            layer.SPSiteURI = App.Current.Resources[_SPSITEURL] as string;
        }

        private void bFullScreen_Click(object sender, RoutedEventArgs e)
        {
            if (!Application.Current.Host.Content.IsFullScreen)
                Application.Current.Host.Content.IsFullScreen = true;
            else
                Application.Current.Host.Content.IsFullScreen = false;
        }

        private void LayerControlButton_Click(object sender, RoutedEventArgs e)
        {
            fpLayer.Open();
        }

        private void bPrint_Click(object sender, RoutedEventArgs e)
        {
            PrintWindow printWindow = new PrintWindow(map.Center, map.ZoomLevel);
            printWindow.ParentMap = map;
            printWindow.Show();
        }

        private void bOVerView_Click(object sender, RoutedEventArgs e)
        {
            fpMini.Open();
        }

        private void bFind_Click(object sender, RoutedEventArgs e)
        {
            fpFind.Open();
        }
    }
}
